<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/inc/taglibs.jsp"%>
<!-- page start from 0, the jsp display from 1 -->
<c:if test="${page.totalCount > 0}">
<div class="page fz12">
<table width="96%" cellspacing="0" cellpadding="0" border="0">
<tr>
	<td>
	<a href="#" onClick="pageView('1_${page.pageSize}')"><fmt:message key="common.pager.html.first"/></a>
	</td>
	<td>
	<c:if test="${page.totalPage - page.pageIndex > 0}">
		<a href="#" onClick="pageView('${page.pageIndex + 1}_${page.pageSize}')"><fmt:message key="common.pager.html.next"/></a>
	</c:if>
	</td>
	<td>
		<c:if test="${page.totalPage > 0}">
			<!-- the displayed page before current page -->
			<c:if test="${page.pageIndex - 2 >= 1}"><!-- current page > 3 -->
				<a href="#" onClick="pageView('${page.pageIndex - 2}_${page.pageSize}')">${page.pageIndex - 2}</a>
				<a href="#" onClick="pageView('${page.pageIndex - 1}_${page.pageSize}')">${page.pageIndex - 1}</a>
			</c:if>
			<c:if test="${page.pageIndex - 2 == 0}"> <!-- current page == 2 -->
				<a href="#" onClick="pageView('${page.pageIndex - 1}_${page.pageSize}')">${page.pageIndex - 1}</a>
			</c:if>
			
			<!-- current page -->
			<a href="#" onClick="pageView('${page.pageIndex}_${page.pageSize}')"><strong><font color="#ff0000">${page.pageIndex}</font></strong></a>
			
			<!-- thie displayed page after current page -->
			<c:if test="${page.totalPage - page.pageIndex - 2 >= 0 }">
				<a href="#" onClick="pageView('${page.pageIndex + 1}_${page.pageSize}')">${page.pageIndex + 1}</a>
				<a href="#" onClick="pageView('${page.pageIndex + 2}_${page.pageSize}')">${page.pageIndex + 2}</a>
			</c:if>
			<c:if test="${page.totalPage - page.pageIndex - 2  == -1}"> <!-- current page == 2 -->
				<a href="#" onClick="pageView('${page.pageIndex + 1}_${page.pageSize}')">${page.pageIndex + 1}</a>
			</c:if>
		</c:if>
	</td>
	<td>
		<c:if test="${page.pageIndex - 1 > 0}"> <!-- make sure current page > 1 show 'prev' -->
			<a href="#" onClick="pageView('${page.pageIndex - 1}_${page.pageSize}')"><fmt:message key="common.pager.html.pre"/></a>
		</c:if>
	</td>
	<td>
		<a href="#" onClick="pageView('${page.totalPage}_${page.pageSize}')"><fmt:message key="common.pager.html.last"/></a>
	</td>
	<td>
		&nbsp;&nbsp;<fmt:message key="common.pager.html.total"/>${page.totalCount}<fmt:message key="common.pager.html.total.record"/>
		&nbsp;&nbsp;<fmt:message key="common.pager.html.total"/>${page.totalPage }<fmt:message key="common.pager.html.total.page"/>
	</td>
	<td>
		&nbsp;&nbsp;
		<a href="javascript:goPagination(this)">
		<fmt:message key="common.pager.html.goto"/>
		</a>
		<input type="text" name="pagination_pageIndex" id="pagination_pageIndex" size="2"/>页
	</td>
</tr>
</table>
</div>
</c:if>
<script>
$(document).ready(function(){
	$('#searchForm_pi').val('<c:out value="${page.pageIndex}"/>_<c:out value="${page.pageSize}"/>');
});
function goPagination(input){
	var pageIndex = document.getElementById('pagination_pageIndex').value;
	var pi = ''+pageIndex + '_<c:out value="${page.pageSize}"/>';
	pageView(pi);
}
function pageView(pi){
	submitSearchForm(pi);
}
</script>